﻿using _2112A_2_MES._chubowen;
using _2112A_2_MES._wangweihao;
using _2112A_2_MES._XiangHe;
using _2112A_2_MES.SuJiaHao;
using _2112A_2_MES.SuJiaHaos;
using _2112A_2_MES.SuJiaHaos.ProductionPiickings;
using _2112A_2_MES.SuJiaHaos.Sasles;
using _2112A_2_MES.SuJiaHaos.StockTakings;
using _2112A_2_MES.SuJiaHaos.ToolTypes;
using _2112A_2_MES.SuJiaHaos.WareHouse;
using _2112A_2_MES.XiangHe.Measuress;
using _2112A_2_MES.XiangHes;
using Autofac.Core;
using AutoMapper.Internal.Mappers;
using Castle.Core.Resource;
using FourGroups.Project;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Test.WangWeiHao;
using Volo.Abp.ObjectMapping;

namespace _2112A_2_MES.Web.Controllers
{
    public class SuJiaHaoController : Controller
    {
        private readonly CustomerService _service;
        private readonly WarehouseService _wareService;
        private readonly ProductionPiickingService _productionPiickingServer;
        private readonly SasleService _sasleService;
        private readonly StockTakingService _stockTakingService;
        private readonly ToolTypeService _toolTypeService;

        public SuJiaHaoController(CustomerService service, WarehouseService wareService, ProductionPiickingService productionPiickingServer, SasleService sasleService, StockTakingService stockTakingService, ToolTypeService toolTypeService)
        {
            _service = service;
            _wareService = wareService;
            _productionPiickingServer = productionPiickingServer;
            _sasleService = sasleService;
            _stockTakingService = stockTakingService;
            _toolTypeService = toolTypeService;
        }

        /// <summary>
        /// 客户管理视图
        /// </summary>
        /// <returns></returns>
        public IActionResult CustomerView()
        {
            return View();
        }
        public async Task<ReturnSelect<object>> GetCustomerList(string? clientCode, string? clientName, string? clientNick, int pageSize, int pageIndex)
        {
            var list = await _service.GetCustomerList(clientCode, clientName, clientNick,pageSize,pageIndex);
            return list;
        }

        /// <summary>
        /// 客户添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult CustomerAddView()
        {
            return View();
        }

        /// <summary>
        /// 客户信息添加
        /// </summary>
        /// <param name="input">客户实体</param>
        /// <returns></returns>
        public async Task<IActionResult> GetCreateCustomer(CreateCustomerDTO input)
        {
            var customer = await _service.GetCreateCustomer(input);
            return Json(new { data = customer, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 客户信息删除
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> DeletedCustomer(int id)
        {
            var customerDel=await _service.DeletedCustomer(id);
            return Json(new { data = customerDel, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 客户修改视图
        /// </summary>
        /// <returns></returns>
        public IActionResult CustomerUpdateView()
        {
            return View();
        }

        /// <summary>
        /// 客户信息反填
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回客户信息实体</returns>
        public async Task<IActionResult> GetCustomers(int id)
        {
            var customers = await _service.GetCustomers(id);
            return Json(new { data = customers, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 客户信息修改
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> UpdateCustomer(CreateCustomerDTO input)
        {
            var customers =await _service.UpdateCustomer(input);
            return Json(new { data = customers, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 仓库管理视图
        /// </summary>
        /// <returns></returns>
        public IActionResult WarehouseSetupView()
        {
            return View();
        }

        /// <summary>
        /// 获取仓库设置
        /// </summary>
        /// <param name="warehouseCode">仓库编码</param>
        /// <param name="warehouseName">仓库名称</param>
        /// <returns>返回仓库设置的泛型集合</returns>
        public async Task<ReturnSelect<object>> GetWmWarehouseList(string? warehouseCode, string? warehouseName, int pageSize, int pageIndex)
        {
            var list = await _wareService.GetWmWarehouseList(warehouseCode, warehouseName, pageSize, pageIndex);
            return list;
        }

        /// <summary>
        /// 仓库添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult WmWareHouseAddView()
        {
            return View();
        }

        /// <summary>
        /// 仓库信息添加
        /// </summary>
        /// <param name="input">仓库实体</param>
        /// <returns></returns>
        public async Task<IActionResult> GetCreateWmWarehouse(CreateWareHuoseDTO input)
        {
            var wmWareHouse = await _wareService.GetCreateWmWarehouse(input);
            return Json(new { data = wmWareHouse, count = 9, code = "0", msg = "" });

        }

        /// <summary>
        /// 仓库信息删除
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> DeleteWmWarehouse(int id)
        {
            var wmWareHouseDel = await _wareService.DeleteWmWarehouse(id);
            return Json(new { data = wmWareHouseDel, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 仓库修改视图
        /// </summary>
        /// <returns></returns>
        public IActionResult WmWarehouseUpdateView()
        {
            return View();
        }

        /// <summary>
        /// 仓库信息反填
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回仓库信息实体</returns>
        public async Task<IActionResult> GetWmWarehouse(int id)
        {
            var customers = await _wareService.GetWmWarehouse(id);
            return Json(new { data = customers, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 仓库信息修改
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> UpdateWmWarehouse(CreateWareHuoseDTO input)
        {
            var wmWarehouse = await _wareService.UpdateWmWarehouse(input);
            return Json(new { data = wmWarehouse, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 生产领料管理视图
        /// </summary>
        /// <returns></returns>
        public IActionResult ProductionPiickingView()
        {
            return View();
        }

        /// <summary>
        /// 获取生产领料列表
        /// </summary>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">页容量</param>
        /// <returns></returns>
        public async Task<ReturnSelect<object>> GetProductionPiickingList(int pageSize, int pageIndex)
        {
            var list = await _productionPiickingServer.GetProductionPiickingList(pageSize, pageIndex);
            return list;
        }

        /// <summary>
        /// 仓库添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult ProductionPiickingAddView()
        {
            return View();
        }

        /// <summary>
        /// 生产领料添加操作
        /// </summary>
        /// <param name="input">生产领料实体</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> GetCreateProductionPiicking(CreateProductionPiickingDTO input)
        {
            var productionPiickings = await _productionPiickingServer.GetCreateProductionPiicking(input);
            return Json(new { data = productionPiickings, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 生产领料删除
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> DeleteProductionPiicking(int id)
        {
            var productionPiickingDel = await _productionPiickingServer.DeleteProductionPiicking(id);
            return Json(new { data = productionPiickingDel, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 客户修改视图
        /// </summary>
        /// <returns></returns>
        public IActionResult ProductionPiickingUpdateView()
        {
            return View();
        }

        /// <summary>
        /// 仓库信息反填
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回仓库信息实体</returns>
        public async Task<IActionResult> GetProductionPiicking(int id)
        {
            var productionPiickings = await _productionPiickingServer.GetProductionPiicking(id);
            return Json(new { data = productionPiickings, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 生产领料信息修改
        /// </summary>
        /// <param name="input">生产领料实体</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> UpdateProductionPiicking(CreateProductionPiickingDTO input)
        {
            var productionPiickings = await _productionPiickingServer.UpdateProductionPiicking(input);
            return Json(new { data = productionPiickings, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 销售退货视图
        /// </summary>
        /// <returns></returns>
        public IActionResult SasleView()
        {
            return View();
        }

        /// <summary>
        /// 获取生产领料列表
        /// </summary>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">页容量</param>
        /// <returns></returns>
        public async Task<ReturnSelect<object>> GetSasleList(int pageSize, int pageIndex)
        {
            var list = await _sasleService.GetSasleList(pageSize, pageIndex);
            return list;
        }

        /// <summary>
        /// 销售退货添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult SasleAddView()
        {
            return View();
        }

        /// <summary>
        /// 销售退货添加
        /// </summary>
        /// <param name="input">销售退货实体</param>
        /// <returns></returns>
        public async Task<IActionResult> GetCreateSasle(CreateSasleDTO input)
        {
            var sasles = await _sasleService.GetCreateSasle(input);
            return Json(new { data = sasles, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 生产领料删除
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> DeleteSasle(int id)
        {
            var sasleDel = await _sasleService.DeleteSasle(id);
            return Json(new { data = sasleDel, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 生产领料修改视图
        /// </summary>
        /// <returns></returns>
        public IActionResult SasleUpdateView()
        {
            return View();
        }

        /// <summary>
        /// 销售退货反填
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回客户信息实体</returns>
        public async Task<IActionResult> GetSasle(int id)
        {
            var sasles = await _sasleService.GetSasle(id);
            return Json(new { data = sasles, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 生产领料信息修改
        /// </summary>
        /// <param name="input">生产领料实体</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> UpdateSasle(CreateSasleDTO input)
        {
            var sasles = await _sasleService.UpdateSasle(input);
            return Json(new { data = sasles, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 库存盘点管理视图
        /// </summary>
        /// <returns></returns>
        public IActionResult StockTakingView()
        {
            return View();
        }

        /// <summary>
        /// 获取生产领料列表
        /// </summary>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">页容量</param>
        /// <returns></returns>
        public async Task<ReturnSelect<object>> GetStockTakingList(int pageSize, int pageIndex)
        {
            var list = await _stockTakingService.GetStockTakingList(pageSize, pageIndex);
            return list;
        }

        /// <summary>
        /// 生产领料添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult StockTakingAddView()
        {
            return View();
        }

        /// <summary>
        /// 销售退货添加
        /// </summary>
        /// <param name="input">销售退货实体</param>
        /// <returns></returns>
        public async Task<IActionResult> GetCreateStockTaking(CreateStockTakingDTO input)
        {
            var stockTakings = await _stockTakingService.GetCreateStockTaking(input);
            return Json(new { data = stockTakings, count = 9, code = "0", msg = "" });
        }


        /// <summary>
        /// 销售退货删除
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> DeleteStockTaking(int id)
        {
            var stockTakingDel = await _stockTakingService.DeleteStockTaking(id);
            return Json(new { data = stockTakingDel, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 销售退货修改视图
        /// </summary>
        /// <returns></returns>
        public IActionResult StockTakingUpdateView()
        {
            return View();
        }

        /// <summary>
        /// 销售退货反填
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回客户信息实体</returns>
        public async Task<IActionResult> GetStockTaking(int id)
        {
            var stockTakings = await _stockTakingService.GetStockTaking(id);
            return Json(new { data = stockTakings, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 生产领料信息修改
        /// </summary>
        /// <param name="input">生产领料实体</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> UpdateStockTaking(CreateStockTakingDTO input)
        {
            var stockTakings = await _stockTakingService.UpdateStockTaking(input);
            return Json(new { data = stockTakings, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 工装夹具视图
        /// </summary>
        /// <returns></returns>
        public IActionResult ToolTypeView()
        {
            return View();
        }

        /// <summary>
        /// 获取生产领料列表
        /// </summary>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">页容量</param>
        /// <returns></returns>
        public async Task<ReturnSelect<object>> GetToolTypeList(int pageSize, int pageIndex)
        {
            var list = await _toolTypeService.GetToolTypeList(pageSize, pageIndex);
            return list;
        }

        /// <summary>
        /// 工装夹具添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult ToolTypeAddView()
        {
            return View();
        }

        /// <summary>
        /// 工装夹具添加
        /// </summary>
        /// <param name="input">销售退货实体</param>
        /// <returns></returns>
        public async Task<IActionResult> GetCreateToolType(CreateToolTypeDTO input)
        {
            var toolTypes = await _toolTypeService.GetCreateToolType(input);
            return Json(new { data = toolTypes, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 工装夹具删除
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> DeleteToolType(int id)
        {
            var toolTypeDel = await _toolTypeService.DeleteToolType(id);
            return Json(new { data = toolTypeDel, count = 9, code = "0", msg = "" });
        }


        /// <summary>
        /// 工装夹具修改视图
        /// </summary>
        /// <returns></returns>
        public IActionResult ToolTypeUpdateView()
        {
            return View();
        }

        /// <summary>
        /// 工装夹具反填
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回工装夹具实体</returns>
        public async Task<IActionResult> GetToolType(int id)
        {
            var toolTypes = await _toolTypeService.GetToolType(id);
            return Json(new { data = toolTypes, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 生产领料信息修改
        /// </summary>
        /// <param name="input">生产领料实体</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> UpdateToolType(CreateToolTypeDTO input)
        {
            var toolTypes = await _toolTypeService.UpdateToolType(input);
            return Json(new { data = toolTypes, count = 9, code = "0", msg = "" });
        }
    }
}

